#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

vector<string> vs {
#include "22.txt"
};

int main() {
    uint64_t ans = 0;
    uint64_t idx = 0;
    sort(vs.begin(), vs.end());
    for (auto s : vs) {
        uint64_t tmp = 0;
        for (char c : s)
            tmp += c - 'A' + 1;
        ans += tmp * ++idx;
    }
    cout << ans << endl;
}